const fp = require('lodash/fp')
const { Maybe, Container } = require('./support')

// 练习1
let maybe = Maybe.of([5, 6, 1])
let ex1 = () => fp.map(item => fp.add(item, item))
// console.log(maybe.map(ex1()))

// 练习2
let xs = Container.of(['do', 'ray', 'me', 'fa', 'so', 'la', 'ti', 'do'])
let ex2 = () => fp.first
// console.log(xs.map(ex2()))

// 练习3
let safeProp = fp.curry(function (x, o) {
  return Maybe.of(o[x])
})
let user = { id: 2, name: 'Albert' }
let ex3 = () => fp.flowRight(fp.first, fp.split(''), fp.prop('name'))(user)
// console.log(ex3())

// 练习4
let ex4 = function (n) {
  return n && parseInt(n)
}
// console.log(ex4(4));